import {fromJS} from "immutable";
import {
    change_account_text,
    change_api_token,
    change_check_status,
    change_pwd_text,
    change_user_info
} from "./actionCreator";


const defaultStatus = fromJS({
    accountText: "distroot02",
    pwdText: "111111",
    checkState: true,
    accountToken:"",
});


export default (status = defaultStatus, action) => {

    switch (action.type) {
        case change_account_text:

            return status.set("accountText", action.data);

        case change_pwd_text:
            return status.set("pwdText", action.data);

        case  change_check_status:
            const newBool = !status.get("checkState");
            return status.set("checkState", newBool);
        case change_user_info:
            return  status.merge({
                accountText:action.account,
                pwdText:action.pwd,
            });

        case change_api_token:

            return  status.set("accountToken",action.token);

        default:
            return status;
    }
}